<?=$this->form ( $this->element->getName (), $this->element->getAttribs (), false ); ?>
<?php
    echo $this->renderElement ( $this->element->codtab );
    echo $this->renderElement ( $this->element->codboton );
    echo $this->renderElement ( $this->element->codboton2 );
    echo $this->renderElement ( $this->element->codseccionlista );
   
    $domConfig = Zend_Registry::get('domConfig'); //esto se crea en el bootstrap
	$array_dedicacion = $domConfig->TIPO_DEDICACION->toArray();
	$array_nivel = $domConfig->TIPO_NIVEL->toArray();
		
	$elementos = array();
	foreach ($this->element as $value){
	    $elementos[$value->getName()] = $value;
	}
?>
<div align="center" width="100%">

<table width="95%" align="center" class="iceDatTbl zebra">
<tr>
	<th>
		Defina el &uacute;ltimo A&ntilde;o y Periodo del cual tiene informaci&oacute;n Ejemplo 2009 - 2:
	</th>
	<th>
		<?php
		    echo str_repeat("&nbsp;",5);
		    echo "Año ".$this->renderElement($this->element->ano);
	        echo $this->element->ano->renderErrors();
	    ?>
	</th>
	<th style="text-align:center;">-</th>
	<th>
	    <?php
		    echo "Periodo ".$this->renderElement($this->element->periodo);
	        echo $this->element->periodo->renderErrors();
	    ?>
	</th>
 </tr>
</table>

 <table width="95%" class="iceDatTbl zebra">
  <tr>
    <th rowspan="2"><div align="center"><strong>A&ntilde;o y Per&iacute;odo</strong></div></th>
    <th rowspan="2"><div align="center"><strong>Dedicaci&oacute;n (2)</strong></div></th>
    <th rowspan="2"><div align="center"><strong>Total</strong></div></th>
    <th colspan="6"><div align="center"><strong>Nivel de formaci&oacute;n (contabilizar solo el mayor nivel    de grado) (1)</strong></div></th>
  </tr>
  <tr>
  <?php     foreach($array_nivel as $keyn => $valuen) { // nivel de formación ?>
    <th><div align="center"><strong><?php echo $valuen;?></strong></div></th>
  <?php }?>
  </tr>
  <?php
     $rowspan = 5;
     
     if ($elementos["ano_1_1"]->getValue()==$elementos["ano_1_2"]->getValue()){
         for ($index1 = 1; $index1 < 6; $index1++) { //años
		     for ($index2 = 2; $index2 > 0; $index2--) { // periodos
	     ?>
				  <tr>
				    <td rowspan="<?php echo $rowspan;?>"><div align="center">
				        <?php
				            echo $this->renderElement ( $elementos["ano_{$index1}_{$index2}"] )." - ";
				            echo $this->renderElement ( $elementos["periodo_{$index1}_{$index2}"] );
				            echo $elementos["ano_{$index1}_{$index2}"]->renderErrors ();
				            echo $elementos["periodo_{$index1}_{$index2}"]->renderErrors ();
				        ?>
				    </div></td>
				    <?php foreach($array_dedicacion as $keyd => $valued) {
				        $rowspan = 0;
				    ?>
				    <td><strong><?php echo $valued;?></strong></td>
				    <td><div align="center"><?php echo $this->renderElement ( $elementos["total_{$index1}_{$index2}_{$keyd}"] );?></div></td>
				    <?php foreach($array_nivel as $keyn => $valuen) { // nivel de formación ?>
				    <td><div align="center"><?php echo $this->renderElement ( $elementos["cantidad_{$index1}_{$index2}_{$keyd}_{$keyn}"] );?></div></td>
					<?php }?>
				  </tr>
				  <?php }
				  $rowspan = 5;
			  }
		  }
     }else{
         for ($index1 = 1; $index1 < 6; $index1++) { //años
		     for ($index2 = 1; $index2 < 3; $index2++) { // periodos
	     ?>
				  <tr>
				    <td rowspan="<?php echo $rowspan;?>"><div align="center">
				        <?php
				            echo $this->renderElement ( $elementos["ano_{$index1}_{$index2}"] )." - ";
				            echo $this->renderElement ( $elementos["periodo_{$index1}_{$index2}"] );
				            echo $elementos["ano_{$index1}_{$index2}"]->renderErrors ();
				            echo $elementos["periodo_{$index1}_{$index2}"]->renderErrors ();
				        ?>
				    </div></td>
				    <?php foreach($array_dedicacion as $keyd => $valued) {
				        $rowspan = 0;
				    ?>
				    <td><strong><?php echo $valued;?></strong></td>
				    <td><div align="center"><?php echo $this->renderElement ( $elementos["total_{$index1}_{$index2}_{$keyd}"] );?></div></td>
				    <?php foreach($array_nivel as $keyn => $valuen) { // nivel de formación ?>
				    <td><div align="center"><?php echo $this->renderElement ( $elementos["cantidad_{$index1}_{$index2}_{$keyd}_{$keyn}"] );?></div></td>
					<?php }?>
				  </tr>
				  <?php }
				  $rowspan = 5;
			  }
		  }
     }
    ?>
  <?php
	if (! $this->element->isStatic ()) :
	?>
    <tr>
		<td colspan="9" class="iceDatTblRow2"><div align="center">
        <?php
		echo $this->renderElement ( $this->element->btnSubmit );
		?>
        </div></td>
	</tr>
	<?php
	endif;
	?>
  
  </table>
</div>
</form>